package com.slg.android.manyanime.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.slg.android.manyanime.R;
import com.slg.android.manyanime.bean.Animation;
import com.slg.android.manyanime.view.FullListView;

import java.util.List;

/**
 * Created by Thinkpad on 2015/3/17.
 */
public class ZhuifanOuterAdapter extends BaseAdapter {

    private Context context;

    private List<List<Animation>> outerdata;

    public ZhuifanOuterAdapter(Context context, List<List<Animation>> outerdata) {
        this.context = context;
        this.outerdata = outerdata;
    }

    @Override
    public int getCount() {
        return outerdata.size();
    }

    @Override
    public Object getItem(int position) {
        return outerdata.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = null;
        if (convertView != null) {
            view = convertView;
        } else {
            view = inflater.inflate(R.layout.item_zhuifan_list, parent, false);
        }
        ViewHolder viewHolder = (ViewHolder) view.getTag();
        if (viewHolder == null) {
            viewHolder = new ViewHolder();
            viewHolder.weekday=(TextView)view.findViewById(R.id.week_day);
            viewHolder.innerList=(FullListView)view.findViewById(R.id.item_innner_listview);
            view.setTag(viewHolder);
        }


        String textInsert = null;
        switch (position) {
            case 0:
                textInsert = "日";
                viewHolder.weekday.setText("周" + textInsert + "更新");
                break;
            case 1:
                textInsert = "一";
                viewHolder.weekday.setText("周" + textInsert + "更新");
                break;
            case 2:
                textInsert = "二";
                viewHolder.weekday.setText("周" + textInsert + "更新");
                break;
            case 3:
                textInsert = "三";
                viewHolder.weekday.setText("周" + textInsert + "更新");
                break;
            case 4:
                textInsert = "四";
                viewHolder.weekday.setText("周" + textInsert + "更新");
                break;
            case 5:
                textInsert = "五";
                viewHolder.weekday.setText("周" + textInsert + "更新");
                break;
            case 6:
                textInsert = "六";
                viewHolder.weekday.setText("周" + textInsert + "更新");
                break;

        }

        viewHolder.innerList.setAdapter(new ZhuifaninnerAdapter(
                context, outerdata.get(position)));
        return view;
    }

    public class ViewHolder {
        public TextView weekday;
        public FullListView innerList;
    }
}
